package cn.doitedu.day03.oo

/**
 * 辅助构造器，是对java主构造器的扩展
 */
class User(val name: String) {

  var gender: String = _
  var age: Int = _

  //定义辅助构造器（方法）
  def this(name: String, gender: String) {
    //辅助构造器第一行，一定要先调用主构造器,或者其他辅助构造器
    this(name)
    this.gender = gender
  }

  def this(name: String, gender: String, age: Int) {
//    this(name)
//    this.gender = gender
//    this.age = age
    this(name, gender)
    this.age = age
  }



}

object User {

  def main(args: Array[String]): Unit = {

    //val u = new User("tom")
    val u = new User("tom", "male")
    println(u.gender)

    val boy = new Boy()

  }




}
